package cn;

import org.junit.runner.RunWith;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.XmlWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;

//http://sishuok.com/forum/blogPost/list/7981.html Spring MVC测试框架详解——服务端测试
//https://github.com/spring-projects/spring-framework/tree/master/spring-test/src/test/java/org/springframework/test/web
/*
 * https://spring.io/blog/2014/03/19/introducing-spring-test-mvc-htmlunit Htmlunit webdirver mockmvc的文章
 * http://www.tuicool.com/articles/mUBZNbq
 * http://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/testing.html#spring-mvc-test-framework
 http://docs.spring.io/spring/docs/4.3.7.RELEASE/spring-framework-reference/htmlsingle/
 https://github.com/spring-projects/spring-framework/blob/master/spring-test/src/test/java/org/springframework/test/web/servlet/samples/
 */
//@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml","classpath:springmvc.xml"})
@ActiveProfiles("production")
@WebAppConfiguration
public class BaseSpring extends AbstractTransactionalJUnit4SpringContextTests{
    protected MockMvc mockMvc;
//
//    @Override
//    public void onStartup(ServletContext container) {
//        ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet((WebApplicationContext)this.applicationContext));
//        registration.setLoadOnStartup(1);
//        registration.addMapping("/");
//    }
}
